# -*- coding: utf-8 -*-
"""
/***************************************************************************
    begin                : 2009-01
    copyright            : (C) 2009 by Volkan Kepoglu
    email                : vkepoglu at gmail.com
 ***************************************************************************/
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
"""

from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.core import *
from qgis.gui import *

class InfoMapTool(QgsMapTool):

 def __init__(self, canvas, button):
  QgsMapTool.__init__(self, canvas)
  self.canvas = canvas
  self.cursor = QCursor(Qt.CrossCursor)
  self.button = button

 def canvasMoveEvent(self,event):
  self.emit( SIGNAL("moved"), {'x': event.pos().x(), 'y': event.pos().y()} )


 def canvasReleaseEvent(self,event):
  if event.button() == Qt.RightButton:
   self.emit( SIGNAL("rightClicked"), {'x': event.pos().x(), 'y': event.pos().y()} )
  else:
   self.emit( SIGNAL("leftClicked"), {'x': event.pos().x(), 'y': event.pos().y()} )


 def activate(self):
  QgsMapTool.activate(self)
  self.canvas.setCursor(self.cursor)
  self.button.setCheckable(True)
  self.button.setChecked(True)


 def deactivate(self):
  self.button.setCheckable(False)
  QgsMapTool.deactivate(self)


 def isZoomTool(self):
  return False